<?php

function smarty_function_get_subcategory_by_category_id($params, &$smarty) {
    //Get value from page
    $category_id = $params['category_id'];
    if($category_id){
      //Query data

      //Check exist user & topic
      $pntables = pnDBGetTables();
      $table  = $pntables['icarrent_subcategory'];
      $column = $pntables['icarrent_subcategory_column'];

      $sql = "SELECT
                $table.$column[id],  
                $table.$column[name]  
              FROM
                $table 
              WHERE
                $table.$column[category_id] = ".$category_id."
              ORDER BY
                $table.$column[name] ASC "
;

      $column = array("subcategory_id", "subcategory_name");
      $result = DBUtil::executeSQL($sql);
      $objectArray = DBUtil::marshallObjects ($result, $column);
      ///var_dump($objectArray);exit;
    }
    if ($objectArray) {
        $smarty->assign('subcategoryArray', $objectArray); 
    } else {
        return "";
    }
}